# -*- coding: utf-8 -*-
import PythonMagick
import os


#python3.x
import tkinter as tk
from tkinter.ttk import *
from tkinter.filedialog import askopenfilename
from tkinter.filedialog import askdirectory

init_path = os.path.dirname(os.path.realpath(__file__))

source_file = askopenfilename(initialdir = init_path,filetypes=(("img", "*.jpg;*.png"),
                                                ("All files", "*.*")))
if len(source_file)>3:
    img = PythonMagick.Image(source_file)
    img.sample('48x48')
    img.write('icon.ico')